package com.yunysha.struts.action;



import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.yunysha.constants.YunyshaConstants;
import com.yunysha.controller.YunyshaController;
import com.yunysha.struts.actionform.DesignMasterForm;



public class DesignMasterAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		try
		{
		String subAction=request.getParameter("subAction")==null?"":request.getParameter("subAction").toString();	
		if(subAction.equalsIgnoreCase("save"))
		{
			
			System.out.println("in save");
			HashMap<String,String> dataMap=new HashMap<String,String>();
			String txtMetalCategory=request.getParameter("txtMetalCategory")==null?"":request.getParameter("txtMetalCategory").toString();
			dataMap.put("txtMetalCategory", txtMetalCategory);
			String txtMetalKt=request.getParameter("txtMetalKt")==null?"":request.getParameter("txtMetalKt").toString();
			dataMap.put("txtMetalKt", txtMetalKt);
			String txtMetalColor=request.getParameter("txtMetalColor")==null?"":request.getParameter("txtMetalColor").toString();
			dataMap.put("txtMetalColor", txtMetalColor);
			String txtMetal14KWt=request.getParameter("txtMetal14KWt")==null?"":request.getParameter("txtMetal14KWt").toString();
			dataMap.put("txtMetal14KWt", txtMetal14KWt);
			String txtMetal18KWt=request.getParameter("txtMetal18KWt")==null?"":request.getParameter("txtMetal18KWt").toString();
			dataMap.put("txtMetal18KWt", txtMetal18KWt);
			//String txtFindingCategory=request.getParameter("txtFindingCategory")==null?"":request.getParameter("txtFindingCategory").toString();
			//dataMap.put("txtFindingCategory", txtFindingCategory);
			String txtFindingKt=request.getParameter("txtFindingKt")==null?"":request.getParameter("txtFindingKt").toString();
			dataMap.put("txtFindingKt", txtFindingKt);
			String txtFindingColor=request.getParameter("txtFindingColor")==null?"":request.getParameter("txtFindingColor").toString();
			dataMap.put("txtFindingColor", txtFindingColor);
			String txtFinding14KWt=request.getParameter("txtFinding14KWt")==null?"":request.getParameter("txtFinding14KWt").toString();
			dataMap.put("txtFinding14KWt", txtFinding14KWt);
			String txtFinding18KWt=request.getParameter("txtFinding18KWt")==null?"":request.getParameter("txtFinding18KWt").toString();
			dataMap.put("txtFinding18KWt", txtFinding18KWt);
			String txtPhotoPath=request.getParameter("txtPhotoPath")==null?"":request.getParameter("txtPhotoPath").toString();
			dataMap.put("txtPhotoPath", txtPhotoPath);
			
		
			YunyshaController yc=new YunyshaController();
			System.out.println("about to call controller");
			yc.saveDesignMaster(dataMap);
			
		}
			
		}catch(Exception e)
		{
			
		}

		String forward = null;
		DesignMasterForm uForm = (DesignMasterForm) form;
		System.out.println("before forward");
		forward = YunyshaConstants.SUCCESS;
		
		return mapping.findForward(forward);
	}
}